<template>
  <div>
    <h1>注册页面</h1>
    <form @submit.prevent="submitForm">
      <input v-model="form.username" placeholder="用户名">
      <input v-model="form.email" placeholder="邮箱" type="email">
      <input v-model="form.password" placeholder="密码" type="password">
      <button type="submit">注册</button>
    </form>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  name: 'Register',
  data() {
    return {
      form: {
        username: '',
        email: '',
        password: ''
      }
    }
  },
  methods: {
    submitForm() {
      axios.post('http://localhost:8080/api/users/register', this.form)
        .then(response => {
          alert('注册成功');
        })
        .catch(error => {
          alert(error.response.data);
        });
    }
  }
}
</script>

<style scoped>
</style>